-
-
Notifications
You must be signed in to change notification settings - Fork 376
ref: convert AutoBreadcrumbTrackingIntegration to Swift #7158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref: convert AutoBreadcrumbTrackingIntegration to Swift #7158
Conversation
Convert SentryAutoBreadcrumbTrackingIntegration from Objective-C to Swift following the SwiftIntegration protocol pattern. Updated the conversion guide with learnings including: - Exposing Objective-C headers via SentryPrivate.h - Runtime initialization pattern for conditionally compiled classes - Typealias dependency injection pattern - Test fixture setup with dependency injection
|
@sentry review |
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
Other
🤖 This preview updates automatically when you update the PR. |
❌ 5 Tests Failed:
View the top 3 failed test(s) by shortest run time
View the full list of 2 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
…yAutoBreadcrumbTrackingIntegration This update adds the @objc annotation to the addBreadcrumb method, allowing it to be accessible from Objective-C code. Additionally, the import statement in the test file has been adjusted for consistency with Swift's SPI usage.
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| edcda5a | 1217.52 ms | 1248.72 ms | 31.20 ms |
| 2e5230b | 1207.41 ms | 1240.41 ms | 33.00 ms |
| 3b01aaf | 1194.98 ms | 1210.36 ms | 15.38 ms |
| 387fbe4 | 1226.19 ms | 1251.98 ms | 25.79 ms |
| 7e93d85 | 1205.28 ms | 1243.71 ms | 38.44 ms |
| 5d67f5d | 1225.33 ms | 1262.76 ms | 37.43 ms |
| 45eb835 | 1210.40 ms | 1233.39 ms | 22.99 ms |
| 37bc095 | 1210.00 ms | 1242.69 ms | 32.69 ms |
| ffe0649 | 1213.35 ms | 1248.64 ms | 35.29 ms |
| c424b6a | 1220.38 ms | 1248.18 ms | 27.80 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| edcda5a | 24.14 KiB | 1.08 MiB | 1.06 MiB |
| 2e5230b | 24.14 KiB | 1.04 MiB | 1.02 MiB |
| 3b01aaf | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| 387fbe4 | 24.14 KiB | 1.07 MiB | 1.04 MiB |
| 7e93d85 | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| 5d67f5d | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| 45eb835 | 24.14 KiB | 1.07 MiB | 1.04 MiB |
| 37bc095 | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| ffe0649 | 24.14 KiB | 1.06 MiB | 1.04 MiB |
| c424b6a | 24.14 KiB | 1.06 MiB | 1.04 MiB |
Previous results on branch: philprime/convert-auto-breadcrumb-tracking-integration
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 02928a5 | 1217.57 ms | 1243.44 ms | 25.86 ms |
| a17d780 | 1210.94 ms | 1251.53 ms | 40.59 ms |
| d98c918 | 1224.55 ms | 1259.49 ms | 34.94 ms |
| d32640b | 1214.98 ms | 1242.67 ms | 27.69 ms |
| bd74c60 | 1216.17 ms | 1249.17 ms | 33.00 ms |
| 424ea88 | 1224.00 ms | 1260.90 ms | 36.90 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 02928a5 | 24.14 KiB | 1.08 MiB | 1.05 MiB |
| a17d780 | 24.14 KiB | 1.09 MiB | 1.06 MiB |
| d98c918 | 24.14 KiB | 1.07 MiB | 1.05 MiB |
| d32640b | 24.14 KiB | 1.07 MiB | 1.05 MiB |
| bd74c60 | 24.14 KiB | 1.07 MiB | 1.04 MiB |
| 424ea88 | 24.14 KiB | 1.07 MiB | 1.05 MiB |
|
@sentry review |
…ting functionality to Swift with updated conditional imports for platform compatibility.
…header file. Adjust usage in InfoForBreadcrumbController to align with new method definition.
Sources/Swift/Integrations/Breadcrumbs/SentryAutoBreadcrumbTrackingIntegration.swift
Show resolved
Hide resolved
…o-breadcrumb-tracking-integration
Sources/Swift/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbs.swift
Show resolved
Hide resolved
Sources/Swift/Integrations/Breadcrumbs/SentryAutoBreadcrumbTrackingIntegration.swift
Show resolved
Hide resolved
Sources/Swift/Integrations/Breadcrumbs/SentryAutoBreadcrumbTrackingIntegration.swift
Show resolved
Hide resolved
Sources/Swift/Integrations/Breadcrumbs/SentryBreadcrumbTracker.swift
Outdated
Show resolved
Hide resolved
Sources/Swift/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbs.swift
Outdated
Show resolved
Hide resolved
itaybre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some small comments
- Store notification observers and remove them in stop() to prevent resource leaks in SentryBreadcrumbTracker - Track and disable battery monitoring and orientation notifications in stop() to prevent resource leaks in SentrySystemEventBreadcrumbs - Inject dateProvider via initializer instead of using singleton
…o-breadcrumb-tracking-integration # Conflicts: # Sources/Sentry/SentrySDKInternal.m # Sources/Sentry/SentrySwizzleWrapperHelper.m # Sources/Sentry/include/SentrySwizzleWrapperHelper.h # Sources/Swift/Core/Integrations/Integrations.swift
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Sources/Swift/Integrations/Breadcrumbs/SentryAutoBreadcrumbTrackingIntegration.swift
Outdated
Show resolved
Hide resolved
- Added a new swizzle method for tracking UIViewController lifecycle events. - Updated conditional UIKit imports to support tvOS and visionOS. - Adjusted test to reflect changes in notification observer count.
… multi-platform support - Modified conditional compilation to include tvOS and visionOS in SentryDependencyContainer. - Added platform checks for battery and orientation notifications in SentrySystemEventBreadcrumbs to ensure proper functionality across iOS, tvOS, and visionOS. - Cleaned up observer removal logic to prevent resource leaks.
…o-breadcrumb-tracking-integration
📜 Description
This PR converts the auto breadcrumb tracking integration and related types from Objective-C to Swift. The main conversion includes:
SentryAutoBreadcrumbTrackingIntegration- Main integration classSentrySystemEventBreadcrumbs- System event breadcrumb trackingAdditionally,
SentryBreadcrumbDelegateandSentryBreadcrumbTrackerwere also converted to Swift due to Swift-Objective-C interoperability compilation issues encountered during the migration. Converting these types to Swift was more reasonable than attempting to fix the complex interop issues, especially given the project's direction toward Swift.The conversion also includes:
UICurrentDeviceProviderto useuiDeviceWrapperfromSentryDependencyContainervia a newSentryUIDeviceWrapperProviderprotocolswizzleViewDidAppearhelper method toSentrySwizzleWrapperHelperto support Swift-based swizzlingSentryAsyncSafeLog.hthat was exposed by stricter SPM build requirements💡 Motivation and Context
This change is part of the ongoing migration from Objective-C to Swift in the Sentry Cocoa SDK. Converting the breadcrumb tracking integration to Swift improves code maintainability, type safety, and consistency with the rest of the Swift codebase.
The additional conversion of
SentryBreadcrumbDelegateandSentryBreadcrumbTrackerwas necessary due to Swift-Objective-C interoperability compilation issues. Rather than attempting to resolve complex interop problems, converting these types to Swift was the more pragmatic approach and aligns with the project's Swift migration goals.💚 How did you test it?
make test-iosSentryAsyncSafeLog.hheader path issue for SPM builds📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled.Closes #6860
Closes #7258